<template>
	<view class="count poRel">
		<view class="poFix wid100" style="background: #e9ffe4;top: 0;z-index: 11;">
			<!-- 状态栏高度 -->
			<view :style="{ height: `${statusBarHeight}px` }"></view>
			<!-- 自定义导航栏高度 并 居中 -->
			<view class="dis disAl disJuC poRel" :style="{height: `${barHeight}px`}">
				<view class="poAbs" style="width: 32rpx;height: 32rpx;left: 22rpx;" @click="fanhui()">
					<image src="../../../static/fanhui.png" class="wh100"></image>
				</view>
				<view class="foSi35" style="line-height: 36rpx;">分享码</view>
			</view>
		</view>
		<view :style="{ height: `${statusBarHeight+barHeight}px` }"></view>
		<view class="poRel" style="z-index: 2;">
			<image :src="urlImage+'/wechatimg/b3.png'" style="height: 1183rpx;" class="wid100"></image>
			<view class="wid90 mar borRad40 hei80 dis disAl disJuC foSi35 coFFF fowe600" @click="baocun()"
				style="margin-top: 50rpx;background-color: #F94B4A;">保存图片</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapActions
	} from 'vuex'
	import {
		utilMixins
	} from "@/common/util-mixins.js"
	import {
		getDw
	} from "@/common/wechat-util"
	import utils from '@/common/utils'
	export default {
		name: 'share',
		data() {
			return {
				statusBarHeight: 0,
				barHeight: 0,
				image: ''
			}
		},
		async onLoad() {
			// 状态栏高度
			this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight;
			// 胶囊数据
			const {
				top,
				height
			} = wx.getMenuButtonBoundingClientRect();
			// 自定义导航栏高度 = 胶囊高度 + 胶囊的padding*2, 如果获取不到设置为38
			this.barHeight = height ? height + (top - this.statusBarHeight) * 2 : 38;
			this.getList()
		},
		methods: {
			baocun() {
				uni.downloadFile({
					url: 'https://img-home.csdnimg.cn/images/20240218021837.png',
					success: (res) => {
						if (res.statusCode === 200) {
							uni.saveImageToPhotosAlbum({
								filePath: res.tempFilePath,
								success: function() {
									uni.showToast({
										title: "保存成功",
										icon: "none"
									});
								},
								fail: function() {
									uni.showToast({
										title: "保存失败，请稍后重试",
										icon: "none"
									});
								}
							});
						}
					}
				})
			},
			async getList() {
				let {
					data
				} = await this.util.request({
					'url': this.api.hydj,
					data: {
						userId: uni.getStorageSync('userId')
					}
				})
				this.list = data
				console.log(data)
			},
			fanhui() {
				uni.navigateBack(1)
			},
		}
	}
</script>

<style scoped lang="scss">
	.count {
		min-height: 100vh;
		background-color: #F6F6F6;
	}
</style>